import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/pages/login/Login'
import Index from '@/pages/index/Index'
Vue.use(Router)

/*
const originalPush = Router.prototype.push;
   Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
};
*/

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Login',
      component: Login,
      meta: {
        title: '登录'
      }
    }, {
      path: '/index',
      name: 'Index',
      component: Index,
      redirect: '/index/mend', // 重定向，第一次进入就进入view，不添加的话第一次进入下面是空白
      children: [
        {
          path: '/index/mend',
          name: 'MendList',
          component: () => import('@/pages/mendList/MendList'),
          meta: {
            title: '我的维修单'
          }
        },
        {
          path: '/index/myWorkOrder',
          name: 'MyWorkOrder',
          component: () => import('@/pages/myWorkOrder'),
          meta: {
            title: '我的维修单'
          }
        },
        {
          path: '/index/finish',
          name: 'FinishList',
          component: () => import('@/pages/finishList/FinishList'),
          meta: {
            title: '已完成订单'
          }
        },
        {
          path: '/index/repair/:id',
          name: 'Repair',
          component: () => import('@/pages/repair/Repair'),
          meta: {
            title: '故障报修'
          }
        },
        {
          path: '/index/researcher',
          name: 'Researcher',
          component: () => import('@/pages/researcher/Researcher'),
          meta: {
            title: '研究院报单'
          }
        },
        {
          path: '/index/district',
          name: 'District',
          component: () => import('@/pages/district/District'),
          meta: {
            title: '片区管理'
          }
        },
        {
          path: '/index/deploy',
          name: 'Deploy',
          component: () => import('@/pages/deploy/Deploy'),
          meta: {
            title: '片区配置'
          }
        },
        {
          path: '/index/service',
          name: 'Service',
          component: () => import('@/pages/service/Service'),
          meta: {
            title: '客服管理'
          }
        },
        {
          path: '/index/case',
          name: 'Case',
          component: () => import('@/pages/case/Case'),
          meta: {
            title: '案例库'
          }
        },
        {
          path: '/index/fault',
          name: 'Fault',
          component: () => import('@/pages/fault/Fault'),
          meta: {
            title: '故障统计'
          }
        },
        {
          path: '/index/serviceStatistics',
          name: 'ServiceStatistics',
          component: () => import('@/pages/serviceStatistics/index'),
          meta: {
            title: '服务统计'
          }
        },
        {
          path: '/index/failureStatistics',
          name: 'FailureStatistics',
          component: () => import('@/pages/failureStatistics/index'),
          meta: {
            title: '故障统计'
          }
        },
        {
          path: '/index/researchOrderStatistics',
          name: 'ResearchOrderStatistics',
          component: () => import('@/pages/researchOrderStatistics/index'),
          meta: {
            title: '研究院工单统计'
          }
        },
        {
          path: '/index/mend/client/:orderNumber',
          name: 'ClientDetail',
          component: () => import('@/pages/clientDetail/ClientDetail'),
          props: true,
          meta: {
            title: '服务单详情'
          }
        },
        {
          path: '/index/mend/sale/:orderNumber/:saleNumber/:suit',
          name: 'SaleDetail',
          component: () => import('@/pages/saleDetail/SaleDetail'),
          props: true,
          meta: {
            title: '售后单详情'
          }
        },
        {
          path: '/index/finish/sale/:orderNumber/:saleNumber/:suit',
          name: 'FinishDetail',
          component: () => import('@/pages/finishDetail/FinishDetail'),
          props: true,
          meta: {
            title: '已关闭订单详情'
          }
        },
        {
          path: '/index/case/detail/:id',
          name: 'CaseDetail',
          component: () => import('@/pages/caseDetail/Detail'),
          props: true,
          meta: {
            title: '案例详情'
          }
        },
        {
          path: '/index/mend/new/:orderNumber',
          name: 'NewBill',
          component: () => import('@/pages/newBill/NewBill'),
          props: true,
          meta: {
            title: '新建工单'
          }
        },
        {
          path: '/index/signMap',
          name: 'signMap',
          component: () => import('@/pages/signMap/index'),
          props: true,
          meta: {
            title: '签到地图'
          }
        },
        {
          path: '/index/productRepair',
          name: 'productRepair',
          component: () => import('@/pages/productRepair/index'),
          props: true,
          meta: {
            title: '产品返修'
          }
        },
        {
          path: '/index/newProductRepair',
          name: 'newProductRepair',
          component: () => import('@/pages/newProductRepair/index'),
          props: true,
          meta: {
            title: '新建返修单'
          }
        },
        {
          path: '/index/productRepairDetail/:id',
          name: 'productRepairDetail',
          component: () => import('@/pages/productRepairDetail/index'),
          props: true,
          meta: {
            title: '返修单详情'
          }
        },
        {
          path: '/index/productRepairStatistics',
          name: 'productRepairStatistics',
          component: () => import('@/pages/productRepairStatistics/index'),
          props: true,
          meta: {
            title: '返修统计'
          }
        },
        {
          path: '/index/bake',
          name: 'Bake',
          component: () => import('@/pages/bake/Bake'),
          props: true,
          meta: {
            title: '插槽的用法'
          }
        }, {
          path: '*',
          name: '404',
          component: () => import('@/pages/404/404'),
          props: true,
          meta: {
            title: '404页面'
          }
        }
      ]
    },
    {
      path: '/city',
      name: 'City',
      component: () => import('@/pages/city/City')
    },
    {
      path: '*',
      name: '404',
      component: () => import('@/pages/404/404')
    }
  ]
})
